package com.gbk.clickhouseservicesave.service;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.task.TaskRejectedException;
import org.springframework.stereotype.Component;

import java.util.concurrent.RejectedExecutionException;

/**
 *@ClassName MessagePublisher
 *@Author: gbk
 *@Description TODO:
 *@Version: 1.0
 */
@Component
@Slf4j
@Data
public class MessagePublisher {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    public void publicMessage(Object obj) {
        try {
            applicationEventPublisher.publishEvent(obj);
        } catch (TaskRejectedException e) {
            log.error("reject Task, detail reject/total -{}",obj);
            log.error("task reject -{}", obj, e);
        }
    }
}
